package basic.datastruct.Map;

import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * @创建人 MBY381
 * @创建时间 2022/4/21 14:25
 * @描述 暂无
 */
public class TreeVsHash {
    public static void main(String[] args) {
        print();
    }
    public static void print(){
        Map<String,Integer> treeMap1=new TreeMap<>(){};
        Map<String,Integer> hashMap=new HashMap<>();
        Comparator<String> reverseCmp=new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return -o1.compareTo(o2);
            }
        };
//
        Map<String,Integer> treeMap2=new TreeMap<>(reverseCmp);
        Map<String,Integer> hashMap3=new HashMap<String,Integer>(8,0.2f);
        Map<Integer,String> map5=new TreeMap<>((a,b)->(b-a));
        hashMap.put("a",1);
        hashMap.put("b",2);
        hashMap.put("e",5);
        hashMap.put("c",3);
        hashMap.put("d",4);

        treeMap1.put("a",1);
        treeMap1.put("b",2);
        treeMap1.put("c",3);
        treeMap1.put("d",4);
        treeMap1.put("e",5);
        treeMap2.put("a",1);
        treeMap2.put("b",2);
        treeMap2.put("c",3);
        treeMap2.put("d",4);
        treeMap2.put("e",5);
        for (Integer i:hashMap.values()
             ) {
            System.out.println("hash   : "+i);
        }
        for (Integer i:treeMap1.values()
        ) {
            System.out.println("tree   : "+i);
        }
        for (Integer i:treeMap2.values()
        ) {
            System.out.println("treeCmp: "+i);
        }
        hashMap.forEach((k,v)->
                System.out.println(k+" "+v)
                );
    }
//    Comparator<TreeNode> cmp1=new Comparator<TreeNode>() {
////            @Override
////            public int compare(TreeNode o1, TreeNode o2) {
////                return 0;
////            }
////        }

}
